Skip to content

Fix notification sounds failing to load in production builds#34

Merged
Sunwuyuan merged 2 commits intomainfrom
copilot/fix-notification-sound-bug
Jan 18, 2026
Merged

Fix notification sounds failing to load in production builds#34
Sunwuyuan merged 2 commits intomainfrom
copilot/fix-notification-sound-bug

Conversation

Copy link
Contributor

Copilot AI commented Jan 18, 2026

Notification sounds were not loading after build because audio files in src/assets/sounds/ were not being copied to the production bundle, while the code referenced them using development-only paths (/src/assets/sounds/${filename}).

Changes

  • Relocated audio assets: Moved 35 sound files from src/assets/sounds/public/sounds/

    • Files in public/ are automatically copied to build output as static assets
  • Updated path resolution:

    export function getSoundPath(filename) {
      if (!filename) return null;
    - return `/src/assets/sounds/${filename}`;
    + return `/sounds/${filename}`;
    }
  • Updated generation script: Modified scripts/generate-sound-list.js to read from public/sounds/

  • Updated component: Fixed local path helper in NotificationSoundSettings.vue

Sound files now work identically in both dev and production, accessible at /sounds/*.mp3 in all environments.

Original prompt

检查并修复构建后无法加载通知声音的bug


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…older

Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 18, 2026

Deploying classworks with  Cloudflare Pages  Cloudflare Pages

Latest commit: d09d135
Status: ✅  Deploy successful!
Preview URL: https://714f4f97.classworks.pages.dev
Branch Preview URL: https://copilot-fix-notification-sou.classworks.pages.dev

View logs

Copilot AI changed the title [WIP] Fix bug preventing notification sound from loading after build Fix notification sounds failing to load in production builds Jan 18, 2026
Copilot AI requested a review from Sunwuyuan January 18, 2026 00:58
@Sunwuyuan Sunwuyuan marked this pull request as ready for review January 18, 2026 00:59
Copilot AI review requested due to automatic review settings January 18, 2026 00:59
@Sunwuyuan Sunwuyuan merged commit b905c43 into main Jan 18, 2026
5 of 7 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where notification sounds failed to load in production builds. The root cause was that audio files in src/assets/sounds/ were not being copied to the production bundle, while the code referenced them using development-only paths. The solution relocates the audio files to the public/ directory and updates all path references accordingly.

Changes:

  • Moved 35 audio files from src/assets/sounds/ to public/sounds/ for proper static asset handling
  • Updated path resolution from /src/assets/sounds/ to /sounds/ in soundList.js, NotificationSoundSettings.vue, and the generation script
  • Updated code comments to reflect the new public directory approach

Reviewed changes

Copilot reviewed 3 out of 38 changed files in this pull request and generated no comments.

File Description
src/utils/soundList.js Updated getSoundPath function to return /sounds/ path instead of /src/assets/sounds/ with updated comment
src/components/settings/NotificationSoundSettings.vue Updated local getSoundPath method to use /sounds/ path with updated comment
scripts/generate-sound-list.js Updated source directory path from ../src/assets/sounds to ../public/sounds and updated generated output path
Comments suppressed due to low confidence (1)

src/components/settings/NotificationSoundSettings.vue:251

  • This component defines its own getSoundPath method which duplicates the functionality already exported from soundList.js. Consider importing and using getSoundPath from soundList.js instead to maintain a single source of truth and avoid code duplication. The soundList.js file already exports this function, and other components like UrgentNotification.vue successfully use the imported version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wuyuancat
Copy link
Collaborator

此拉取请求已在 Kernyr 上被提及。那里可能有相关详细信息:

http://kernyr.wuyuan.dev/t/topic/174/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants